﻿using System;
using Csla.Xaml;
using HeThongThongTin.Library;
using System.ComponentModel;
using Utility;

namespace HeThongThongTin.UI.SL.DanhMuc.DM_LoaiHoSo
{
    public class DM_LoaiHoSo_ViewModel : ViewModel<HeThongThongTin.Library.DM_LoaiHoSo>
    {
        #region Event Declare
        public delegate void ChildList_AddedNew_EventHandler(object sender, ChildListAddedNewArgs e);
      
        public event ChildList_AddedNew_EventHandler ChildList_AddedNew;
        public event EventHandler LoadCompleted;
        #endregion

        #region Refresh Model
        public DM_LoaiHoSo_ViewModel()
        {
            BeginRefresh("NewDM_LoaiHoSo");
            
        }

        public DM_LoaiHoSo_ViewModel(int Khoa)
        {
            BeginRefresh("GetDM_LoaiHoSo", Khoa);
           
        }

        public void NewDM_LoaiHoSoViewModel()
        {
            BeginRefresh("NewDM_LoaiHoSo");
            
        }

        public void GetDM_LoaiHoSoViewModel(int Khoa)
        {
            BeginRefresh("GetDM_LoaiHoSo", Khoa);
        }

       
        public void SaveAndNew()
        {
            BeginSave();
            NewDM_LoaiHoSoViewModel();
        }
        protected override void OnRefreshed()
        {
            base.OnRefreshed();
            if (Model != null)
            {
                Model.DM_LoaiHoSo_GiayToKemTheos.AddedNew += new EventHandler<Csla.Core.AddedNewEventArgs<DM_LoaiHoSo_GiayToKemTheoChild>>(DM_LoaiHoSo_GiayToKemTheos_AddedNew);
                Model.DM_LoaiHoSo_QuyTrinhXuLys.AddedNew += new EventHandler<Csla.Core.AddedNewEventArgs<DM_LoaiHoSo_QuyTrinhXuLyChild>>(DM_LoaiHoSo_QuyTrinhXuLys_AddedNew);

                if (LoadCompleted != null)
                {
                    LoadCompleted(this, new EventArgs());
                }
            }
        }
        #endregion
        
        #region Add DM_LoaiHoSo Details Item
        public void AddDM_LoaiHoSo_GiayToKemTheoItem()
        {
            Model.DM_LoaiHoSo_GiayToKemTheos.AddNewItem(Model.Khoa);
        }

        public void AddDM_LoaiHoSo_QuyTrinhXuLyItem()
        {
            Model.DM_LoaiHoSo_QuyTrinhXuLys.AddNewItem(Model.Khoa);
        }
       

        void DM_LoaiHoSo_GiayToKemTheos_AddedNew(object sender, Csla.Core.AddedNewEventArgs<DM_LoaiHoSo_GiayToKemTheoChild> e)
        {
            OnChildList_AddedNew(sender, new ChildListAddedNewArgs("DM_LoaiHoSo_GiayToKemTheos"));
        }

        void DM_LoaiHoSo_QuyTrinhXuLys_AddedNew(object sender, Csla.Core.AddedNewEventArgs<DM_LoaiHoSo_QuyTrinhXuLyChild> e)
        {
            OnChildList_AddedNew(sender, new ChildListAddedNewArgs("DM_LoaiHoSo_QuyTrinhXuLys"));
        }
       

        protected virtual void OnChildList_AddedNew(object sender, ChildListAddedNewArgs e)
        {
            if (ChildList_AddedNew != null)
            {
                //Invokes the delegates.
                ChildList_AddedNew(sender, e);
            }
        }

      
       
       
        #endregion

        #region Delete DM_LoaiHoSo Details Item

        public void DeleteDM_LoaiHoSo_GiayToKemTheoItem(int Index)
        {
            Model.DM_LoaiHoSo_GiayToKemTheos.DeleteItem(Index);
        }
        public void DeleteDM_LoaiHoSo_QuyTrinhXuLyItem(int Index)
        {
            Model.DM_LoaiHoSo_QuyTrinhXuLys.DeleteItem(Index);
        }
        
        #endregion

        
    }
}
